package org.kazuhiko.pokemon3d.physics;

import static org.lwjgl.opengl.GL11.GL_FRONT_AND_BACK;
import static org.lwjgl.opengl.GL11.*;

import org.kazuhiko.pokemon3d.game.Pokemon3D;
import org.lwjgl.util.vector.Vector3f;

public class Collision
{	
	public enum Side
	{
		FRONT,
		BACK,
		LEFT,
		RIGHT,
		BOTTOM,
		TOP;
	}
	
	private float x;
	private float y;
	private float z;
	private float width;
	private float height;
	private float depth;
	
	private Vector3f color;
	
	private Side side;
	
	public Collision( float x, float y, float z, float width, float height, float depth, Side side )
	{
		color = new Vector3f( 1f, 0, 0 );
		
		this.x = x;
		this.y = y;
		this.z = z;
		this.width = width;
		this.height = height;
		this.depth = depth;
		this.side = side;
	}
	
	public Collision( float x, float y, float z, float width, float height, float depth, Side side, Vector3f color )
	{
		this( x, y, z, width, height, depth, side );
		this.color = color;
	}
	
	public float getX()
	{
		return x;
	}
	
	public float getY()
	{
		return y;
	}
	
	public float getZ()
	{
		return z;
	}
	
	public float getWidth()
	{
		return width;
	}
	
	public float getHeight()
	{
		return height;
	}
	
	public float getDepth()
	{
		return depth;
	}
	
	public Side getSide()
	{
		return side;
	}
	
	public Vector3f getColor()
	{
		return color;
	}
	
	public void draw( int polygonMode )
	{
		glPolygonMode( GL_FRONT_AND_BACK, polygonMode );
		
		glBegin( GL_QUADS );
		{
			glColor3f( color.x, color.y, color.z );
			
			if( side == Side.BACK )
			{
				glVertex3f( x, y + height, z );
				glVertex3f( x + width, y + height, z );
				glVertex3f( x + width, y, z );
				glVertex3f( x, y , z );
			}
			else if( side == Side.FRONT )
			{
				glVertex3f( x + width, y + height, z );
				glVertex3f( x, y + height, z );
				glVertex3f( x, y, z );
				glVertex3f( x + width, y , z );
			}
		}
		glEnd();
		
		glPolygonMode( GL_FRONT_AND_BACK, Pokemon3D.mode );
	}
}
